package com.atguigu.ssyx.home.controller;

import com.atguigu.ssyx.common.auth.AuthContextHolder;
import com.atguigu.ssyx.common.result.Result;
import com.atguigu.ssyx.home.service.ItemService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * ClassName: ItemApiController
 * Package: com.atguigu.ssyx.home.controller
 * Description:
 * User: fzykd
 *
 * @Author: LQH
 * Date: 2023-10-04
 * Time: 13:59
 */

@Api("商品详情信息接口")
@RestController
@RequestMapping("/api/home")
public class ItemApiController {

    @Autowired
    private ItemService itemService;

    @ApiOperation("根据skuId得到商品详情的信息")
    @GetMapping("item/{id}")
    public Result index(@PathVariable Long id){
        //要的到当前的用户Id
        Long userId = AuthContextHolder.getUserId();
        //id是skuId
        Map<String,Object> map = itemService.item(id,userId);
        return Result.ok(map);
    }
}
